package pl.ydp.storage.events
{
	import mx.resources.IResourceManager;
	import mx.resources.ResourceManager;
	
	
	/**
	 * Class provides additional info about Storage error codes.  
	 * @see pl.ydp.editor.storage.StorageErrorEvent  
	 */
	 
	public class StorageErrorInfo
	{
		
		/**
		 * error dictionary.
		 */ 
		protected static var m_errorCodes:Array = new Array ();
		
		protected static var resourceManager:IResourceManager = ResourceManager.getInstance(); 
		
		m_errorCodes[1] = resourceManager.getString("uted", "put.file.io.error");
		m_errorCodes[2] = resourceManager.getString("uted", "put.file.security.error");
		m_errorCodes[3] = resourceManager.getString("uted", "load.file.io.error");
		m_errorCodes[4] = resourceManager.getString("uted", "load.file.security.error");
		m_errorCodes[5] = resourceManager.getString("uted", "save.file.io.error");
		m_errorCodes[6] = resourceManager.getString("uted", "save.file.security.error");
		m_errorCodes[7] = resourceManager.getString("uted", "list.dir.io.error");
		m_errorCodes[8] = resourceManager.getString("uted", "list.dir.security.error");
		m_errorCodes[9] =  resourceManager.getString("uted", "list.layout.io.error");
		m_errorCodes[10] = resourceManager.getString("uted", "list.layout.security.error");
		m_errorCodes[11] = resourceManager.getString("uted", "remove.file.io.error");
		m_errorCodes[12] = resourceManager.getString("uted", "remove.file.security.error");
		m_errorCodes[13] = resourceManager.getString("uted", "file.name.error");
		m_errorCodes[14] = resourceManager.getString("uted", "copy.file.io.error");
		m_errorCodes[15] = resourceManager.getString("uted", "copy.file.security.error");
		m_errorCodes[16] = resourceManager.getString("uted", "property.list.io.error");
		m_errorCodes[17] = resourceManager.getString("uted", "property.list.security.error");
		m_errorCodes[18] = resourceManager.getString("uted", "no.free.space.error");
		m_errorCodes[19] = resourceManager.getString("uted", "make.icon.io.error");
		m_errorCodes[20] = resourceManager.getString("uted", "make.icon.security.error");
		m_errorCodes[21] = resourceManager.getString("uted", "set.begin.io.error");
		m_errorCodes[22] = resourceManager.getString("uted", "set.begin.security.error");
		m_errorCodes[23] = resourceManager.getString("uted", "end.begin.io.error");
		m_errorCodes[24] = resourceManager.getString("uted", "end.begin.security.error");
		m_errorCodes[25] = resourceManager.getString("uted", "ping.security.error");
		m_errorCodes[26] = resourceManager.getString("uted", "ping.io.error");
		
		public function StorageErrorInfo()
		{
		}
			
		/**
		 * Provides text information about a specific storage error code.     
		 * @param _errorCode error code.
		 * @returns error text info.
		 * @see pl.ydp.storage.StorageErrorEvent
		 */
		public static function resolveCode ( _errorCode:Number ):String{
			
			return  ( m_errorCodes[_errorCode] == null ) ? resourceManager.getString("uted", "unknown.error") : m_errorCodes[_errorCode];  
		}
		
		/**
		 * Provides text information about a specific storage error event.     
		 * @param event instance of StorageErrorEvent class.
		 * @returns error text info.
		 * @see pl.ydp.storage.StorageErrorEvent
		 */
		public static function resolveEvent ( event:StorageErrorEvent ):String{
			
			var errCode:Number = event.errorCode;
			var details:String = (event.details && event.details.length ) ? "\n(<i>"+event.details+ "</i>)" : ""; 
			return  ( m_errorCodes[errCode] == null ) ? resourceManager.getString("uted", "unknown.error") + details : 
														m_errorCodes[errCode] + details;  
		}  

	}
}